package edu.hrbu.spring.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * Xml文件配置通知
 *
 * @author 徐登宇
 */
public class MyAspect2 {

    // 访问权限修饰符 返回值类型 全限定性类名 方法名 形参列表
    public void beforeAdvice() {
        System.out.println("【MyAspect2】的前置通知");
    }

    public void afterAdvice() {
        System.out.println("【MyAspect2】的后置通知");
    }

    public void afterReturningAdvice(Object res) {
        System.out.println("【MyAspect2】的返回通知，返回结果为：" + res);
    }

    public void afterThrowingAdvice(Exception e) {
        System.out.println("【MyAspect2】的异常通知，异常为："+e.getMessage());
    }

    public Object aroundAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕通知开始");
        Object res = proceedingJoinPoint.proceed();
        System.out.println("环绕通知结束");
        return res;
    }

}
